package org.atovio.coolexam.mapper;

import org.apache.ibatis.annotations.*;
import org.atovio.coolexam.entity.Subject;

import java.util.List;
import java.util.Map;

public interface SubjectMapper {

    @Insert("insert into t_subject(id, name, t_user_id) values (#{id}, #{name}, #{tUserId})")
    int insert(Subject subject);

    List<Subject> selectSelective(@Param("criteria") Map<String, Object> criteria);

    @Select("select * from t_subject where id = #{id};")
    Subject selectById(Integer id);

    /**
     * 根据自定义条件查询记录条数
     *
     * @param criteria 自定义条件
     * @return 记录条数
     */
    int selectCountSelective(@Param("criteria") Map<String, Object> criteria);

    @Update("update t_subject set name = #{name}, t_user_id = #{tUserId} where id = #{id};")
    int update(Subject subject);

    @Update("update t_subject set name = #{name} where id = #{id};")
    int updateNameById(Integer id, String name);

    @Update("update t_subject set t_user_id = #{tUserId} where id = #{id};")
    int updateTUserIdById(Integer id, Integer tUserId);

    @Delete("delete from t_subject where id = #{id};")
    int deleteById(Integer id);
}
